package org.jiulou.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/** 
 * @RequestMapping("/userinfo") 具有层次关系，方法级的将在类一级@RequestMapping之一, 
 * 如下面示例, 访问方法级别的@RequestMapping("/new"),则URL为 /userinfo/new 
 */  
//@Controller  
//@RequestMapping("/userinfo")  
public class UserInfoController {
	
    //默认多列排序,example: username desc,createTime asc  
    protected static final String DEFAULT_SORT_COLUMNS = null; 
      
//    private UserInfoManager userInfoManager;  
//      
//    private final String LIST_ACTION = "redirect:/userinfo";  
//      
//    /**  
//     * 通过spring自动注入 
//     **/  
//    public void setUserInfoManager(UserInfoManager manager) {  
//        this.userInfoManager = manager;  
//    }  
//      
//    /** 列表 */  
//    @RequestMapping  
//    public ModelAndView index(HttpServletRequest request,HttpServletResponse response,UserInfo userInfo) {  
//        PageRequest<Map> pageRequest = newPageRequest(request,DEFAULT_SORT_COLUMNS);  
//        //pageRequest.getFilters(); //add custom filters  
//          
//        Page page = this.userInfoManager.findByPageRequest(pageRequest);  
//        savePage(page,pageRequest,request);  
//        return new ModelAndView("/userinfo/list","userInfo",userInfo);  
//    }  
//      
//    /** 进入新增 */  
//    @RequestMapping(value="/new")  
//    public ModelAndView _new(HttpServletRequest request,HttpServletResponse response,UserInfo userInfo) throws Exception {  
//        return new ModelAndView("/userinfo/new","userInfo",userInfo);  
//    }  
//      
//    /** 显示 */  
//    @RequestMapping(value="/{id}")  
//    public ModelAndView show(@PathVariable Long id,HttpServletRequest request,HttpServletResponse response) throws Exception {  
//        UserInfo userInfo = (UserInfo)userInfoManager.getById(id);  
//        return new ModelAndView("/userinfo/show","userInfo",userInfo);  
//    }  
//      
//    /** 编辑 */  
//    @RequestMapping(value="/{id}/edit")  
//    public ModelAndView edit(@PathVariable Long id,HttpServletRequest request,HttpServletResponse response) throws Exception {  
//        UserInfo userInfo = (UserInfo)userInfoManager.getById(id);  
//        return new ModelAndView("/userinfo/edit","userInfo",userInfo);  
//    }  
//      
//    /** 保存新增 */  
//    @RequestMapping(method=RequestMethod.POST)  
//    public ModelAndView create(HttpServletRequest request,HttpServletResponse response,UserInfo userInfo) throws Exception {  
//        userInfoManager.save(userInfo);  
//        return new ModelAndView(LIST_ACTION);  
//    }  
//      
//    /** 保存更新 */  
//    @RequestMapping(value="/{id}",method=RequestMethod.PUT)  
//    public ModelAndView update(@PathVariable Long id,HttpServletRequest request,HttpServletResponse response) throws Exception {  
//        UserInfo userInfo = (UserInfo)userInfoManager.getById(id);  
//        bind(request,userInfo);  
//        userInfoManager.update(userInfo);  
//        return new ModelAndView(LIST_ACTION);  
//    }  
//      
//    /** 删除 */  
//    @RequestMapping(value="/{id}",method=RequestMethod.DELETE)  
//    public ModelAndView delete(@PathVariable Long id,HttpServletRequest request,HttpServletResponse response) {  
//        userInfoManager.removeById(id);  
//        return new ModelAndView(LIST_ACTION);  
//    }  
//  
//    /** 批量删除 */  
//    @RequestMapping(method=RequestMethod.DELETE)  
//    public ModelAndView batchDelete(@RequestParam("items") Long[] items,HttpServletRequest request,HttpServletResponse response) {  
//          
//        for(int i = 0; i < items.length; i++) {  
//              
//            userInfoManager.removeById(items[i]);  
//        }  
//        return new ModelAndView(LIST_ACTION);  
//    }
}
